﻿namespace KxParser.Lexer
{
    /// <summary>
    /// Represents definition of token
    /// </summary>
    public sealed class TokenDefinition
    {
        public readonly IMatcher Matcher;
		public readonly string RegularExpression;
        public readonly object Token;
		public readonly bool IsIgnored;

        /// <summary>
        /// TokenDefinition constructor
        /// </summary>
        /// <param name="regex"></param>
        /// <param name="token"></param>
		/// <param name="isIgnored"></param>
        public TokenDefinition(string regex, object token, bool isIgnored = false)
        {
            Matcher = new RegexMatcher(regex);
			RegularExpression = regex;
            Token = token;
			IsIgnored = isIgnored;
        }

		public override string ToString()
		{
			return string.Format("{0}{1} <=> {2}", (IsIgnored)? "*" : "", Token, Matcher);
		}
    }
}




